import React, {Component} from "react";
import {inject, observer} from "mobx-react";
import QueryItem from "../QueryItem"
import {Link} from "react-router-dom";

@inject("queryStore")
@observer
class QuerySuccess extends Component {
    constructor(props) {
        super(props);
        this.handleClick = this.handleClick.bind(this);
    }

    handleClick() {
        // this.props.queryStore.setPositionQuery(false);
        this.props.queryStore.setFlag(-1);
    }

    render() {
        const results = this.props.queryStore.results;
        const {province, city} = this.props;
        return (
            <div className="PositionQuerySuccess">
                <span className="Title">查询结果</span>
                <div className="List">
                    <span className="Sum">共有{results.length}个校友在{province}{city}</span>
                    {results.map(item => (<QueryItem item={item}/>))}
                </div>
                <Link to='/queryAlumnu'>
                    <button className="Accurate_btn" onClick={this.handleClick}>返回查询校友主界面</button>
                </Link>
            </div>
        )
    }
}

export default QuerySuccess;